package com.sumainfor.pc.gmio.controller.assistant;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sumainfor.common.util.FieldCheckUtil;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.pc.gmio.service.QuestionnaireService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author Jack Chen
 * @Create 2019-01-23 17:13
 * 问卷中心
 */
@RestController
@RequestMapping("/questionnaire")
public class QuestionnaireController {

    @Autowired
    private QuestionnaireService qs;

    /**
     * 主页列表
     *
     * @param page
     * @param params
     * @return
     */
    @RequestMapping("/selectTableList")
    public JsonResult selectTableList(Page page, @RequestParam Map<String, Object> params) {
        return qs.selectTableList(page, params);
    }

    /**
     * 获得详情数据
     *
     * @param tenSurId
     * @return
     */
    @RequestMapping("/getQuestionnaireInfo")
    public JsonResult getQuestionnaireInfo(String tenSurId) {
        return qs.getQuestionnaireInfo(tenSurId);
    }

    /**
     * 提交线上与线下建议
     *
     * @param params
     * @return
     */
    @PostMapping("/key/submitSurvey")
    public JsonResult submitSurvey(@RequestBody Map<String, Object> params) {
        if (!FieldCheckUtil.isMapFieldNotNull(params, "TenId", "Answer", "TenType", "Picture")) {
            return JsonResult.errorForEmpty();
        }
        return qs.submitSurvey(params);
    }

}
